package Utils 
{
	import flash.text.TextField;
	/**
	 * ...
	 * @author Serg de Adelantado
	 */
	public class TextUtils 
	{		
		public function TextUtils() 
		{			
		}
		
		static public function ColoredString(AColor:String, AString:String):String
		{
			return "<font color='" + AColor + "'>" + AString + "</font>";
		}
		
		static public function AdjustTextSize(AText:TextField):void
		{
			AText.width = AText.textWidth + 4;
			AText.height = AText.textHeight + 4;
		}
		/**
		 * Function generates numerator by integer value, depending on
		 * forms, provided by arguments.
		 * @param	ACount 				Value for numerator generation
		 * @param	ANominative 		1, 21, 31, etc.
		 * @param	AGenitiveSingular 	2, 3, 4, 22, 23, 24, etc.
		 * @param	AGenitivePlural 	5, 6, 7, 8, 9, 10, etc.		 
		 * @langversion	3.0
		 */
		static public function Numerator(ACount:int, ANominative:String, AGenitiveSingular:String, AGenitivePlural:String):String
		{
			var vResult:String = "";
			var vLastDigit:int = ACount % 10;
			var vLastTwoDigits:int = ACount % 100;		
			
			if ((vLastDigit == 1) && (vLastTwoDigits != 11))
			{
				vResult = ANominative;
			}
			else if(((vLastDigit == 2) && (vLastTwoDigits != 12)) ||
					((vLastDigit == 3) && (vLastTwoDigits != 13)) ||
					((vLastDigit == 4) && (vLastTwoDigits != 14)))
			{
				vResult = AGenitiveSingular;
			}
			else
			{
				vResult = AGenitivePlural;
			}		
			return vResult;
		}
		/**
		 * Function converts one-digits int numbers into two-digits
		 * by adding a "0" char before the number.
		 * @param	ANumber
		 * A number to convert
		 * @return
		 * Converted number
		 */
		static public function AddZeroForward(ANumber:int):String
		{
			return ANumber < 10 ? '0' + ANumber : ANumber.toString();
		}
	}
}